package com.kjsb.service.impl;

import com.kjsb.dao.ProjectCategoryMapper;
import com.kjsb.entity.ProjectCategory;
import com.kjsb.service.ProjectCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 *
 * 项目类业务处理实体类
 * @author shi lintong
 * @data 2022年 11月 25日15：00
 */
@Service
public class ProjectCategoryServiceImpl implements ProjectCategoryService {

    @Autowired
    private ProjectCategoryMapper progectCategoryMapper;

    /**
     * 查询全部项目类并返回
     * @return
     */
    @Override
    public List<ProjectCategory> getAll() {
        List<ProjectCategory> projectCategories = progectCategoryMapper.selectList(null);
        return projectCategories ;
    }
    /**
     * 添加一个项目类
     * @return
     */
    @Override
    public Boolean save(ProjectCategory projectCategory) {
        int flag = progectCategoryMapper.insert(projectCategory);
        return flag>0;
    }
    /**
     * 修改一个项目类
     * @return
     */
    @Override
    public Boolean updateCategoryName(ProjectCategory projectCategory) {
        int flag = progectCategoryMapper.updateById(projectCategory);
        return flag>0;
    }
    /**
     * 通过项目类id查询项目类并返回
     * @return
     */
    @Override
    public ProjectCategory getOneById(int categoryid) {
        ProjectCategory projectCategory = progectCategoryMapper.selectById(categoryid);

        return projectCategory;
    }

    /**
     * 通过项目类id删除一个项目类
     * @return
     */
    @Override
    public Boolean removeById(int categoryid) {
        int flag = progectCategoryMapper.deleteById(categoryid);
        return flag>0;
    }
}
